import 'dart:convert';

import 'package:flutter_bilibili/http/request/base_request.dart';

// 网络请求抽象类
abstract class HiNetAdapter<T>{
  Future<HiNetResponse<T>> send<T>(BaseRequest request);
}

// 统一网络层返回格式
class HiNetResponse<T> {
  HiNetResponse({this.data, this.statusCode: 0, this.request, this.statusMessage, this.extra});
  T? data;
  BaseRequest? request;
  int? statusCode;
  String? statusMessage;
  dynamic extra;

  @override
  String toString() {
    if (data is Map) {
      return json.encode(data);
    }
    return super.toString();
  }
}